import { Module } from '@nestjs/common';
import { UserModule } from './modules/user/user.module';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { getConfig } from './utils';
import { redisStore } from 'cache-manager-redis-yet';
import { RedisClientOptions } from 'redis';
import { CacheModule, CacheStore } from '@nestjs/cache-manager';
import { AppController } from './app.controller';
import { AppService } from './app.service';

@Module({
  imports: [CacheModule.register<RedisClientOptions>({
    isGlobal: true,
    store: redisStore as any,
    // url: `redis://${getConfig('REDIS_CONFIG').host}:${getConfig('REDIS_CONFIG').port}`,
    // socket: {
    //   host: getConfig('REDIS_CONFIG').host,
    //   port: getConfig('REDIS_CONFIG').port,
    // },
    password: getConfig('REDIS_CONFIG').auth,
    database: getConfig('REDIS_CONFIG').db,
    ttl: 5000 * 2000,
  }), ConfigModule.forRoot({ ignoreEnvFile: true, isGlobal: true, load: [getConfig] }), UserModule,],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule { }
